package com.lzw.mall.admin.mapper;

import com.lzw.mall.admin.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lizhenwei
 * @since 2023-03-17
 */
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user where username=#{userName}")
    User selectByUsername(String userName);

    List<User> selectListPage(@Param("keyword") String keyword,@Param("sex") String sex);

    @Select("select * from user where username=#{username} and id<>#{id}")
    List<User> selectByUsernameAndId(String username, Integer id);

    void deletes(Integer[] ids);

    @Select("select * from user where id=#{id}")
    User doSelectById(Integer id);

    @Update("update user set username=#{username},sex=#{sex},name=#{name},phone=#{phone},avatar=#{avatar} where id=#{id}")
    void doUpdateById(@Param("id") Integer id,@Param("username")  String username,@Param("sex")  String sex,@Param("name")  String name,@Param("phone")  String phone,@Param("avatar")  String avatar);

    @Update("update user set password=#{password} where id=#{id}")
    void updatePassword(@Param("password") String password,@Param("id") Integer id);

    @Update("update user set password='e10adc3949ba59abbe56e057f20f883e' where id=#{id}")
    void updateMima(Integer id);
}
